package com.casino.tool;

import java.util.ArrayList;
import java.util.List;

public class RandomHitTest {
	int[] hitCount = new int[53];

	public void hit(P p) {
		for (int i = 2; i < 15; i++) {
			for (int j = 1; j < 5; j++) {
				if (p.getNum() == i && p.getColor() == j) {
					hitCount[(i - 2) * 4 + j]++;
					return;
				}
			}
		}
	}

	public void hit(P p, List<P> lastPList) {
		for (int i = 2; i < 15; i++) {
			for (int j = 1; j < 5; j++) {
				if (p.getNum() == i && p.getColor() == j && lastPList.contains(p)) {
					hitCount[(i - 2) * 4 + j]++;
					return;
				}
			}
		}
	}

	public void printHit() {
		for (int i = 0; i < 52; i++) {
			System.out.print(hitCount[i]);
			System.out.print("  ");
			if ((i + 1) % 4 == 0) {
				System.out.println("");
			}

		}
	}

	public static void main(String args[]) {
		RandomHitTest test = new RandomHitTest();
		CSM csm = new CSM(6, 7);
		List<P> lastRoundPList = new ArrayList<P>();

		int s=0;
		for (int i = 0; i < 1000000; i++) {
			List<P> plist = new ArrayList<P>();
			for (int j = 0; j < 16; j++) {
				P p = csm.dealRandomCard();
				plist.add(p);
				
				
				
				test.hit(p, lastRoundPList);
			}
			if(csm.getRealCount()>=1){
				s++;
			}
			csm.returnCardsToMachine();
			lastRoundPList.clear();
			lastRoundPList.addAll(plist);
			
			
		}
		System.out.print(s*1.0/1000000);
		test.printHit();
	}
}
